package com.TeamJigsaw.DanteTrail.Views;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import net.miginfocom.swing.MigLayout;

import com.TeamJigsaw.DanteTrail.Views.Interfaces.PartyStatusViewInterface;

public class PartyStatusView extends JPanel implements PartyStatusViewInterface{
	
	private JButton btnBack, btnWagonInventory;
	private JLabel statusLabel_1, staminaLabel_1, diseaseLabel_1, hungerLabel_1, statusLabel_2, staminaLabel_2, diseaseLabel_2, hungerLabel_2,
	statusLabel_3, staminaLabel_3, diseaseLabel_3, hungerLabel_3, statusLabel_4, staminaLabel_4, diseaseLabel_4, hungerLabel_4;
	private String htmlStart, htmlEnd;
	private JPanel playerPanel;
	private JPanel memberPanel2;
	private JPanel memberPanel3;
	private JPanel memberPanel1;
	
	public PartyStatusView()
	{
		setSize(new Dimension(700,700));
		setLayout(new MigLayout("", "[50:50:50][200px:200px:200px][150:150:150][200:200:200]", "[][200px:200px:200px][50:50:50][200:200:200][50:50:50][50:50:50]"));
		htmlStart = "<html><font size=\"4\" color=\"#FFFFFF\"><b>";
		htmlEnd = "</b></font></html>";
		
		
		initialize();
	}
	
	public void initialize()
	{
		playerPanel = new JPanel();
		playerPanel.setBorder(new TitledBorder(null, "Player", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		add(playerPanel, "cell 1 1,grow");
		playerPanel.setLayout(new MigLayout("", "[20:20:20][][20:20:20][][20:20:20]", "[][20:20:20][][20:20:20][][20:20:20][]"));
		
		JLabel lblStatus = new JLabel(htmlStart+"Status:"+htmlEnd);
		playerPanel.add(lblStatus, "cell 1 0");
		
		statusLabel_1 = new JLabel("New label");
		playerPanel.add(statusLabel_1, "cell 3 0");
		
		JLabel lblHunger = new JLabel(htmlStart+"Hunger:"+htmlEnd);
		playerPanel.add(lblHunger, "cell 1 2");
		
		hungerLabel_1 = new JLabel("New label");
		playerPanel.add(hungerLabel_1, "cell 3 2");
		
		JLabel lblStamina = new JLabel(htmlStart+"Stamina:"+htmlEnd);
		playerPanel.add(lblStamina, "cell 1 4");
		
		staminaLabel_1 = new JLabel("New label");
		playerPanel.add(staminaLabel_1, "cell 3 4");
		
		JLabel lblDisease = new JLabel(htmlStart+"Disease:"+htmlEnd);
		playerPanel.add(lblDisease, "cell 1 6");
		
		diseaseLabel_1 = new JLabel("New label");
		playerPanel.add(diseaseLabel_1, "cell 3 6");
		
		memberPanel1 = new JPanel();
		memberPanel1.setBorder(new TitledBorder(null, "Member 1", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		add(memberPanel1, "cell 3 1,grow");
		memberPanel1.setLayout(new MigLayout("", "[20:20:20][][20:20:20][][20:20:20]", "[][20:20:20][][20:20:20][][20:20:20][]"));
		
		JLabel label_8 = new JLabel(htmlStart+"Status:"+htmlEnd);
		memberPanel1.add(label_8, "cell 1 0");
		
		statusLabel_2 = new JLabel("New label");
		memberPanel1.add(statusLabel_2, "cell 3 0");
		
		JLabel label_10 = new JLabel(htmlStart+"Hunger:"+htmlEnd);
		memberPanel1.add(label_10, "cell 1 2");
		
		hungerLabel_2 = new JLabel("New label");
		memberPanel1.add(hungerLabel_2, "cell 3 2");
		
		JLabel label_11 = new JLabel(htmlStart+"Stamina:"+htmlEnd);
		memberPanel1.add(label_11, "cell 1 4");
		
		staminaLabel_2 = new JLabel("New label");
		memberPanel1.add(staminaLabel_2, "cell 3 4");
		
		JLabel label_12 = new JLabel(htmlStart+"Disease:"+htmlEnd);
		memberPanel1.add(label_12, "cell 1 6");
		
		diseaseLabel_2 = new JLabel("New label");
		memberPanel1.add(diseaseLabel_2, "cell 3 6");
		
		memberPanel2 = new JPanel();
		memberPanel2.setBorder(new TitledBorder(null, "Member 2", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		add(memberPanel2, "cell 1 3,grow");
		memberPanel2.setLayout(new MigLayout("", "[20:20:20][][20:20:20][][20:20:20]", "[][20:20:20][][20:20:20][][20:20:20][]"));
		
		JLabel label = new JLabel(htmlStart+"Status:"+htmlEnd);
		memberPanel2.add(label, "cell 1 0");
		
		statusLabel_3 = new JLabel("New label");
		memberPanel2.add(statusLabel_3, "cell 3 0");
		
		JLabel label_2 = new JLabel(htmlStart+"Hunger:"+htmlEnd);
		memberPanel2.add(label_2, "cell 1 2");
		
		hungerLabel_3 = new JLabel("New label");
		memberPanel2.add(hungerLabel_3, "cell 3 2");
		
		JLabel label_4 = new JLabel(htmlStart+"Stamina:"+htmlEnd);
		memberPanel2.add(label_4, "cell 1 4");
		
		staminaLabel_3 = new JLabel("New label");
		memberPanel2.add(staminaLabel_3, "cell 3 4");
		
		JLabel label_6 = new JLabel(htmlStart+"Disease:"+htmlEnd);
		memberPanel2.add(label_6, "cell 1 6");
		
		diseaseLabel_3 = new JLabel("New label");
		memberPanel2.add(diseaseLabel_3, "cell 3 6");
		
		memberPanel3 = new JPanel();
		memberPanel3.setBorder(new TitledBorder(null, "Member 3", TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		add(memberPanel3, "cell 3 3,grow");
		memberPanel3.setLayout(new MigLayout("", "[20:20:20][][20:20:20][][20:20:20]", "[][20:20:20][][20:20:20][][20:20:20][]"));
		
		JLabel label_16 = new JLabel(htmlStart+"Status:"+htmlEnd);
		memberPanel3.add(label_16, "cell 1 0");
		
		statusLabel_4 = new JLabel("New label");
		memberPanel3.add(statusLabel_4, "cell 3 0");
		
		JLabel label_18 = new JLabel(htmlStart+"Hunger:"+htmlEnd);
		memberPanel3.add(label_18, "cell 1 2");
		
		hungerLabel_4 = new JLabel("New label");
		memberPanel3.add(hungerLabel_4, "cell 3 2");
		
		JLabel label_20 = new JLabel(htmlStart+"Stamina:"+htmlEnd);
		memberPanel3.add(label_20, "cell 1 4");
		
		staminaLabel_4 = new JLabel("New label");
		memberPanel3.add(staminaLabel_4, "cell 3 4");
		
		JLabel label_22 = new JLabel(htmlStart+"Disease:"+htmlEnd);
		memberPanel3.add(label_22, "cell 1 6");
		
		diseaseLabel_4 = new JLabel("New label");
		memberPanel3.add(diseaseLabel_4, "cell 3 6");
		
		btnBack = new JButton("Back");
		add(btnBack, "cell 1 5,grow");
		
		btnWagonInventory = new JButton("Wagon And Inventory");
		add(btnWagonInventory, "cell 3 5,grow");
	}

	@Override
	public void setStatuses(String[] status) {
		statusLabel_1.setText(htmlStart+status[0]+htmlEnd);
		statusLabel_2.setText(htmlStart+status[1]+htmlEnd);
		statusLabel_3.setText(htmlStart+status[2]+htmlEnd);
		statusLabel_4.setText(htmlStart+status[3]+htmlEnd);
		
	}

	@Override
	public void setStaminas(String[] stamina) {
		staminaLabel_1.setText(htmlStart+stamina[0]+htmlEnd);
		staminaLabel_2.setText(htmlStart+stamina[1]+htmlEnd);
		staminaLabel_3.setText(htmlStart+stamina[2]+htmlEnd);
		staminaLabel_4.setText(htmlStart+stamina[3]+htmlEnd);
		
	}

	@Override
	public void setHungers(String[] hunger) {
		hungerLabel_1.setText(htmlStart+hunger[0]+htmlEnd);
		hungerLabel_2.setText(htmlStart+hunger[1]+htmlEnd);
		hungerLabel_3.setText(htmlStart+hunger[2]+htmlEnd);
		hungerLabel_4.setText(htmlStart+hunger[3]+htmlEnd);
		
	}

	@Override
	public void setDiseases(String[] disease) {
		diseaseLabel_1.setText(htmlStart+disease[0]+htmlEnd);
		diseaseLabel_2.setText(htmlStart+disease[1]+htmlEnd);
		diseaseLabel_3.setText(htmlStart+disease[2]+htmlEnd);
		diseaseLabel_4.setText(htmlStart+disease[3]+htmlEnd);
		
	}

	@Override
	public void setBackListener(ActionListener listen) {
		btnBack.addActionListener(listen);
		
	}

	@Override
	public void setWagonInventoryListener(ActionListener listen) {
		btnWagonInventory.addActionListener(listen);
		
	}

	@Override
	public void setNames(String[] names) {
		playerPanel.setBorder(new TitledBorder(null, names[0], TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		memberPanel1.setBorder(new TitledBorder(null, names[1], TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		memberPanel2.setBorder(new TitledBorder(null, names[2], TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		memberPanel3.setBorder(new TitledBorder(null, names[3], TitledBorder.LEADING, TitledBorder.ABOVE_TOP, null, null));
		
	}

	@Override
	public boolean listenersExist() {
		if(btnBack.getActionListeners().length > 0)
			return true;
		
		return false;
	}
	
	@Override
	public void paintComponent(Graphics g) {
		ImageIcon img = new ImageIcon("resources\\stone_texture.jpg");
	    g.drawImage(img.getImage(), 0, 0, null);
	  }

}
